package com.fr.lintcode;

public class Q719 {

    /**
     * @param str: the given string
     * @return: the maximum value
     */
    public int calcMaxValue(String str) {
        // write your code here
    	if (str == null || str.length() == 0) {
    		return 0;
    	}
    	int length =str.length();
    	int first = str.charAt(0) - '0';
    	for(int i = 1; i < length; i ++) {
    		int second = str.charAt(i) - '0';
    		int value1 = first + second;
    		int value2 = first * second;
    		first = value1 > value2 ? value1 : value2;
    	}
    	return first;
    }

}
